-
Notifications
You must be signed in to change notification settings - Fork 52
Fix PositionGroup.fetch_position_info() returning empty DataFrame when merge IDs are non-chronological #1475
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Co-authored-by: edeno <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a bug in PositionGroup.fetch_position_info() where concatenated position data from multiple merge IDs could return an empty DataFrame when the merge IDs were not fetched in chronological order.
Key Changes:
- Added
.sort_index()to ensure position data is chronologically sorted before time-based slicing - Created test to verify the fix prevents empty DataFrames and ensures monotonically increasing time indices
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/spyglass/decoding/v1/core.py |
Added .sort_index() call before .loc[min_time:max_time] slice to ensure concatenated position data is sorted chronologically |
tests/decoding/test_core.py |
Added test test_position_group_non_chronological_order to verify position data is properly sorted and non-empty after fetching |
Comments suppressed due to low confidence (2)
tests/decoding/test_core.py:2
- Import of 'pd' is not used.
import pandas as pd
tests/decoding/test_core.py:3
- Import of 'np' is not used.
import numpy as np
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1475 +/- ##
=======================================
Coverage 71.12% 71.12%
=======================================
Files 114 114
Lines 13306 13306
=======================================
Hits 9464 9464
Misses 3842 3842
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: Copilot <[email protected]>
Added sort_index() before .loc[min:max] slicing in clusterless.py, core.py, and sorted_spikes.py to prevent empty DataFrame results when indices are unsorted. Includes a regression test in test_core.py to verify correct behavior and address issue #1471.
PositionGroup.fetch_position_info()returns an empty DataFrame when position merge IDs are fetched in non-chronological order (e.g., alphabetically by UUID rather than by time). Pandas.loc[min:max]slicing on an unsorted index returns empty results.Changes
.sort_index()before.loc[]slice infetch_position_info()(line 232)test_position_group_non_chronological_order()to verify sorted outputExample
Without the fix, concatenating non-chronological position data fails:
The fix ensures correct behavior regardless of fetch order:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.